package com.dang.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

/**
 * Action 基本封装 
 * @author 但劲松
 * 
 * 获得基本request response session 三大对象
 */
@Controller
public class BaseAction  extends ActionSupport implements ServletResponseAware, ServletRequestAware{

	/**
	 *  统一采用 1L序列化对象
	 */
	private static final long serialVersionUID = 1L;
	
	private HttpServletRequest request ;                //request 对象
	private HttpServletResponse response;               //response 对象 
	private HttpSession session;						//session 对象
	
	
	//——————————————————————————————业务方法区域——————————————————————————————————————//
	/**
	 * 缺省方法    , 模板方法
	 */
	@Override
	public String execute(){
		try{
			/*
			 *  核心 业务逻辑 
			 */
		}catch(Exception e){
			//异常处理
			e.printStackTrace();
		}
		return SUCCESS;
	}
	
	
	//——————————————————————————get set 方法区域—————————————————————————————————————//
	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
		session = request.getSession();					//直接设置session 获取纯净的session对象
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response = response ;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	
	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public HttpSession getSession() {
		return session;
	}

	
}
